<template>
    <view>
        <view style="height: 100vh">
            <view style="height: 160rpx">
                <BasicNavbar title="账号工具" :canBack="true" />
            </view>
            <scroll-view scroll-y="true"
                style="width: 100vw; height: calc(100vh - 160rpx);padding: 0 30rpx; box-sizing: border-box;">
                <view v-for="item, i in navList" :key="item.text">
                    <view class="flex between item-center" style="width: 100%; height: 100rpx;"
                        @click="onClickNavList(item)">
                        <div class="flex item-center">
                            <image style="width: 72rpx; height: 48rpx; margin-right: 48rpx"
                                :src="`../../static/images/user/tool${i + 1}.svg`" />
                            <div class="text" style="font-size: 32rpx">{{ item.text }}</div>
                        </div>
                        <u-icon name="arrow-right"></u-icon>
                    </view>
                </view>
            </scroll-view>
        </view>
    </view>
</template>

<script>
import { notificationFun} from '@/utils/PrjUtils';
export default {
    data() {
        return {
            navList: [
                {
                    text: '换绑手机号',
                },
                {
                    text: '修改密码',
                },
                {
                    text: '账号找回',
                },
                {
                    text: '退出登录',
                },
            ]
        }
    },
    computed: {},
    methods: {
        onClickNavList(item) {
            switch (item.text) {
                case "退出登录":
                    this.onLoginOut();
                    break;
                default:
                    let obj = JSON.stringify(item)
                    uni.navigateTo({
                        url: `/pages/accountTools/accountOperation?obj=${obj}`
                    })
                    break;
            }
        },
        onLoginOut() {
            uni.showModal({
                title: '温馨提示',
                content: '您确定退出当前账号吗？',
                success: (res) => {
                    if (res.confirm) {
                        this.loginData = {};
                        this.userData = {};
                        uni.removeStorageSync('loginData')
                        uni.removeStorageSync('appKey')
                        notificationFun('退出成功！');
                        uni.navigateTo({
                            url: '/pages/login/login'
                        })
                    } else if (res.cancel) {
                        //   点取消
                    }
                }
            });
        },

    }
}
</script>

<style lang="scss">
page {
    background: #fff !important;
}
</style>